<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="title">
            <p:messages id="messages" closable="true" showDetail="false" autoUpdate="true"  />
            <p:growl id="messagegrowl"  />
            <h2><a href="#" class="back" onclick="history.go(-1)"/>#{managerPesquisarProjeto.projetoVisualizar.nome}</h2>
        </ui:define>

        <ui:define name="body">
            <script type="text/javascript">
                $(document).ready(function(){
                    $(".tog").hide();
                });
            
                function tog(){
                    $(".tog").toggle(200);
                }
            </script>
            <script  type="text/javascript" src="media/js/autoNumeric.js"></script>

            <h:form id="projetoForm"  enctype="multipart/form-data">            

                <div class="buttonAction" style="float: right">
                    <p:button title="Editar" icon="ui-icon-pencil" value="Editar"
                              styleClass="ui-priority-primary" rendered="#{managerPesquisarProjeto.habilitarEdicao()}"
                              href="editarprojeto.xhtml?eProjeto=#{managerPesquisarProjeto.projetoVisualizar.id}" />
                    <p:commandButton  
                        title="Imprimir" icon="ui-icon-print" value="Imprimir"
                        ajax="false" update="@form" process="@this"
                        onclick="this.form.target='_blank'"
                        actionListener="#{managerPesquisarProjeto.relatorio()}" />
                </div>
                <div class="clear" />

                <p:panel id="projetoPanel" styleClass="container_24 clearfix" >
                    <h2>Projeto</h2>
                    <p:outputLabel value="Nome:" styleClass="grid_3" for="nomeInputText"/>
                    <h:outputText styleClass="grid_15"  id="nomeInputText" value="#{managerPesquisarProjeto.projetoVisualizar.nome}"  />

                    <p:outputLabel value="Estágio:" styleClass="grid_3" for="estagioProjetoInputText"/>
                    <h:outputText styleClass="grid_2"  id="estagioProjetoInputText" 
                                  value="#{managerPesquisarProjeto.projetoVisualizar.estagio} %"  />

                    <div class="clear"/>

                    <p:outputLabel value="Gestor:" styleClass="grid_3" for="gestorInputText"/>
                    <h:outputText styleClass="grid_20" id="gestorInputText" 
                                  value="#{managerPesquisarProjeto.projetoVisualizar.gestor}"/>

                    <div class="clear"/>
                    <p:outputLabel  for="secInput"
                                    value="Campus : " 
                                    styleClass="grid_3"/>  
                    <h:outputText styleClass="grid_20" id="secInput" value="#{managerPesquisarProjeto.projetoVisualizar.secretaria.nome}"/>


                    <div class="clear"/>

                    <p:outputLabel value="Responsável Projeto:" styleClass="grid_5" style="margin-left: -61px" for="respInputText"/>
                    <h:outputText styleClass="grid_20" id="respInputText" 
                                  value="#{managerPesquisarProjeto.projetoVisualizar.responsavel.nome}"/>


                    <div class="clear"/>
                    <!--                        <hr/>-->


                    <p:outputLabel value="Usuários Relacionados:" styleClass="grid_5 tog" style="margin-left: -60px;" />
                    <p:dataTable id="tableUsuario" var="item" 
                                 value="#{managerPesquisarProjeto.projetoVisualizar.acompanhantes}" 
                                 styleClass="grid_20  tog" rowIndexVar="rowid" 
                                 style="white-space: pre-wrap;"
                                 rowKey="#{item.id}" emptyMessage="Nenhum registro">  
                        <f:facet name="header">
                            <p:outputLabel value="" />
                        </f:facet>
                        <p:column sortBy="nome" headerText="Nome" width="300"> 
                            <p:outputLabel value="#{item.nome}"/>
                        </p:column>
                        <p:column sortBy="telefone" headerText="Secretaria" width="150"> 
                            <p:outputLabel value="#{item.setor.nome} - #{item.setor.secretaria.nome}"/>
                        </p:column>
                        <p:column sortBy="telefone" headerText="Telefone" width="150"> 
                            <p:outputLabel value="#{item.telefone}"/>
                        </p:column>
                        <p:column sortBy="email" headerText="Email" width="300"> 
                            <p:outputLabel value="#{item.email}"/>
                        </p:column>

                    </p:dataTable>

                    <div class="clear"/>

                    <p:outputLabel value="Início de Vigência:" styleClass="grid_4" style="margin-left: -26px;" 
                                   for="inicioVigenciaInputText"/>
                    <h:outputText styleClass="grid_8 omega" value="#{managerPesquisarProjeto.projetoVisualizar.vigenciaInicial}" 
                                  id="inicioVigenciaInputText" >
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>

                    <p:outputLabel value="Fim de Vigência:" styleClass="grid_6 alpha" for="fimVigenciaInputText"/>
                    <h:outputText styleClass="grid_8" value="#{managerPesquisarProjeto.projetoVisualizar.vigenciaFinal}" 
                                  id="fimVigenciaInputText" >
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>

                    <div class="clear"/>
                    <p:outputLabel value="Descrição:" styleClass="grid_3" for="descInputText"/>
                    <h:outputText styleClass="grid_20" id="descInputText" value="#{managerPesquisarProjeto.projetoVisualizar.descricao}"/>

                    <div class="clear"/>


                    <h2 class="tog">Localização</h2>

                    <div class="clear"/>


                    <p:outputLabel value="CEP:" styleClass="grid_3 tog" />
                    <h:outputText  styleClass="grid_9 tog" value="#{managerPesquisarProjeto.projetoVisualizar.endereco.cep}" />

                    <p:outputLabel value="Número: " styleClass="grid_3  tog"  />
                    <h:outputText styleClass="grid_8  tog"
                                  value="#{managerPesquisarProjeto.projetoVisualizar.endereco.numero}" />

                    <div class="clear"/>

                    <p:outputLabel value="Logradouro:" styleClass="grid_3  tog"  />
                    <h:outputText  styleClass="grid_9 tog" 
                                   value="#{managerPesquisarProjeto.projetoVisualizar.endereco.logradouro}" />


                    <p:outputLabel value="Bairro: " styleClass="grid_3  tog"  />
                    <h:outputText  styleClass="grid_8 tog" 
                                   value="#{managerPesquisarProjeto.projetoVisualizar.endereco.bairro}" />

                    <div class="clear"/>

                    <p:outputLabel value="Complemento: " styleClass="grid_3  tog"  />
                    <h:outputText  styleClass="grid_20 tog" 
                                   value="#{managerPesquisarProjeto.projetoVisualizar.endereco.compl}" />



                    <div class="clear"/>

                    <h2>Empresa</h2>

                    <p:outputLabel value="Razão Social:" styleClass="grid_3" for="empresaInputText"/>
                    <h:outputText styleClass="grid_20" id="empresaInputText" 
                                  value="#{managerPesquisarProjeto.projetoVisualizar.empresa.nomeFantasia}"/>

                    <div class="clear"/>

                    <p:outputLabel value="CNPJ:" styleClass="grid_3 tog" for="cnpjInputText"/>
                    <h:outputText styleClass="grid_20  tog" id="cnpjInputText" 
                                  value="#{managerPesquisarProjeto.projetoVisualizar.empresa.cnpj}"/>

                    <div class="clear"/>
                    <p:outputLabel value="Responsável do Projeto:" styleClass="grid_5 tog" 
                                   style="margin-left: -60px;" for="responsavelInputText"/>
                    <h:outputText styleClass="grid_20 tog" id="responsavelInputText" 
                                  value="#{managerPesquisarProjeto.projetoVisualizar.responsavel.nome}"/>


                    <div class="clear"/>
                    <h2>Financeiro</h2>

                    <p:outputLabel value="Linha de Financiamento:" styleClass="grid_5 tog" 
                                   style="margin-left: -60px;" for="financiamentoInputText"/>
                    <h:outputText styleClass="grid_9 tog" id="financiamentoInputText" 
                                  value="#{managerCriarProjeto.projeto.linhaFinanciamento}"/>

                    <p:outputLabel value="Data Assinatura:" styleClass="grid_4 tog" style="margin-left: -2px;" 
                                   for="signatureInputText"/>
                    <h:outputText styleClass="grid_8 tog" value="#{managerCriarProjeto.projeto.dataAssinatura}" 
                                  id="signatureInputText" >
                        <f:convertDateTime pattern="dd/MM/yyyy" />
                    </h:outputText>

                    <div class="clear"/>


                    <p:outputLabel value="Valor Global:" styleClass="grid_3" for="orcInputText"/>
                    <h:outputText styleClass="grid_20" id="orcInputText" value="#{managerPesquisarProjeto.projetoVisualizar.orcado}">
                        <f:convertNumber type="currency" locale="pt,BR"/>
                    </h:outputText>

                    <div class="clear"/>

                    <p:outputLabel value="Contrapartida:" styleClass="grid_3 tog" for="contraInputText"/>
                    <h:outputText styleClass="grid_20 tog" id="contraInputText" 
                                  value="#{managerPesquisarProjeto.projetoVisualizar.contraPartida}">
                        <f:convertNumber type="currency" locale="pt,BR"/>
                    </h:outputText>

                    <div class="clear"/>

                    <p:outputLabel value="Valor do Repasse:" styleClass="grid_4 tog" style="margin-left: -27px;" for="repasseInputText"/>
                    <h:outputText styleClass="grid_20 tog" id="repasseInputText" 
                                  value="#{managerPesquisarProjeto.projetoVisualizar.repasse}">
                        <f:convertNumber type="currency" locale="pt,BR"/>
                    </h:outputText>

                    <div class="clear"/>
                    <p:outputLabel value="Total de Lançamentos:" styleClass="grid_5" 
                                   style="margin-left: -62px;" for="totalInputText"/>
                    <h:outputText styleClass="grid_20" id="totalInputText" 
                                  value="#{managerPesquisarProjeto.totalLancamentos}"
                                  style="color: #{managerPesquisarProjeto.projetoVisualizar.repasse.compareTo(managerPesquisarProjeto.totalLancamentos) eq 1 or 
                                                  managerPesquisarProjeto.projetoVisualizar.repasse.compareTo(managerPesquisarProjeto.totalLancamentos) eq 0 ?'green':'red; font-weight:bold;'}">
                        <f:convertNumber type="currency" locale="pt,BR"/>
                    </h:outputText>



                    <div class="clear"/>

                    <h2>Anexos</h2>

                    <p:panel id="anexosprojetoPanel" styleClass="container_24 clearfix" style="margin-left: -2%;">

                        <p:outputLabel value="" styleClass="grid_3" style="font-weight: bold;" />
                        <h:outputText value="Não há anexos!" rendered="#{empty managerPesquisarProjeto.projetoVisualizar.anexos}" 
                                      styleClass="grid_4" />

                        <div class="grid_20">
                            <ui:repeat value="#{managerPesquisarProjeto.projetoVisualizar.anexos}" var="a">
                                <p:panel styleClass="grid_5">
                                    <h:outputLink  
                                        value="#{a.tipo ne 'application/pdf' ? 'viewImage.xhtml':'show'}" title="#{a.tipo}"  
                                        target="_blank" >

                                        <div style="width: 100%;" class="grid_4">

                                            <p:graphicImage id="anexoImagem"
                                                            styleClass="image grid_3" rendered="#{a.tipo ne 'application/pdf'}"
                                                            style="margin-left:3%; width: 80px;"
                                                            url="show/?annex=#{a.url.concat('thumbnail.').concat(a.nome)}" />

                                            <p:graphicImage id="anexoPdf"
                                                            styleClass="image grid_3" rendered="#{a.tipo eq 'application/pdf'}"
                                                            style="margin-left:3%; width: 80px;" 
                                                            url="media/images/pdf.jpeg" />

                                            <div class="clear"/>
                                            <p:outputLabel  value="#{managerPesquisarProjeto.nomeAnexo(a)}" 
                                                            for="anexoImagem"
                                                            style="margin-left:1%; width: 100px;" rendered="#{a.tipo ne 'application/pdf'}"/>

                                            <p:outputLabel for="anexoPdf"
                                                           value="#{managerPesquisarProjeto.nomeAnexoPdf(a)}" 
                                                           style="margin-left:1%; width: 100px;" rendered="#{a.tipo eq 'application/pdf'}"/>
                                        </div>
                                        <f:param name="annex" value="#{a.url.concat(a.nome)}"/>
                                    </h:outputLink>
                                </p:panel>
                            </ui:repeat>
                        </div>
                    </p:panel>
                    <p:commandLink  process="@this" immediate="true" update="@this" onclick="tog();"
                                    style="float: right;font-size: 0.9em;" value="+ Detalhes do Projeto" />

                    <div class="clear"/>
                </p:panel>

                <br/>
                <h3 class="subtitle">Situações</h3>
                <p:panel id="situacaoPanel" styleClass="situacaoSelect container_24 clearfix" >
                    <p:commandButton value="Novo"
                                     icon="ui-icon-plusthick" styleClass="ui-priority-primary" 
                                     style="margin-top: -50px; margin-right: 0px; float: right;"
                                     update="@this" process="@this" onclick="situacaoDlg.show();"  />

                    <ui:repeat id="repeatsituacao" varStatus="count" value="#{managerPesquisarProjeto.situacoesVisualizar}" var="r">
                        <p:panel id="panelrepeatsituacao" styleClass="grid_23 "  toggleable="true" collapsed="true" >
                            <f:facet name="header">
                                <div class="grid_23 clearfix">

                                    <h:outputLabel value="#{r.dataEntrada}">
                                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                                    </h:outputLabel>
                                    <p:outputLabel value=" - #{r.titulo} - #{r.projetoStatus}"/>
                                    <div style="float: right;" class="link-icon24 link-icon24-1">#{r.comentarios.size()}</div>
                                    <p:outputLabel rendered="#{r.estagio ne null}" value="#{r.estagio} % " 
                                                   style="margin-right: 10px;float: right;"/>
                                </div>
                            </f:facet>
                            <div style="right:0 ; margin-top: -10px; position: absolute; font-size: 0.8em;">
                                <h:outputText rendered="#{r.dataCriacao ne null}" value="Criado por: #{r.usuario.nome} em " />
                                <h:outputText  value="#{r.dataCriacao}" >
                                    <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                                </h:outputText>
                            </div>
                            <div class="clear"/>

                            <p:outputLabel value="Título:" styleClass="grid_3" />
                            <h:outputText styleClass="grid_20"  style="white-space: pre-wrap;" value="#{r.titulo}"  />
                            <div class="clear"/>

                            <p:outputLabel value="Descrição:" styleClass="grid_3" />
                            <h:outputText styleClass="grid_20" style="white-space: pre-wrap;"  value="#{r.descricao}"  />
                            <div class="clear"/>

                            <p:outputLabel value="Data:" styleClass="grid_3" />
                            <h:outputText styleClass="grid_20" value="#{r.dataEntrada}">
                                <f:convertDateTime pattern="dd/MM/yyyy" />
                            </h:outputText>

                            <p:outputLabel   value="Empresa:" styleClass="grid_3"/>
                            <p:selectBooleanCheckbox disabled="true" label="Notificar" styleClass="grid_2" 
                                                     value="#{r.notificar}" />

                            <p:outputLabel  value="Secretaria" styleClass="grid_2"/>
                            <p:selectBooleanCheckbox  disabled="true" label="Notificar" styleClass="grid_4" 
                                                      value="#{r.notificarempresa}" />
                            <div class="clear"/>

                            <p:outputLabel  value="Secretaria:" styleClass="grid_3"/>  
                            <h:outputText value="#{r.usuarionotificado.nome}" styleClass="grid_20" />

                            <div class="clear"/>

                            <p:outputLabel value="Responsável: " styleClass="grid_3" />
                            <h:outputText styleClass="grid_20" id="respprojetodlg"
                                          value="#{managerPesquisarProjeto.usuarioNotificar.nome}"/>


                            <div class="clear"/>
                            <hr/>
                            <div class="clear"/>

                            <p:panel id="anexossituacaoPanel" styleClass="container_24 clearfix" style="margin-left: -2%;">

                                <p:outputLabel value="Anexos:" styleClass="grid_3" style="font-weight: bold;" />
                                <h:outputText value="Não há anexos!" rendered="#{empty r.anexos}" 
                                              styleClass="grid_4" />

                                <div class="grid_20">
                                    <ui:repeat value="#{r.anexos}" var="a">
                                        <p:panel styleClass="grid_5">
                                            <h:outputLink  
                                                value="#{a.tipo ne 'application/pdf' ? 'viewImage.xhtml':'show'}" title="#{a.tipo}"  
                                                target="_blank" >

                                                <div style="width: 100%;" class="grid_4">

                                                    <p:graphicImage id="anexoImagem"
                                                                    styleClass="image grid_3" rendered="#{a.tipo ne 'application/pdf'}"
                                                                    style="margin-left:3%; width: 80px;"
                                                                    url="show/?annex=#{a.url.concat('thumbnail.').concat(a.nome)}" />

                                                    <p:graphicImage id="anexoPdf"
                                                                    styleClass="image grid_3" rendered="#{a.tipo eq 'application/pdf'}"
                                                                    style="margin-left:3%; width: 80px;" 
                                                                    url="media/images/pdf.jpeg" />

                                                    <div class="clear"/>
                                                    <p:outputLabel  value="#{managerPesquisarProjeto.nomeAnexo(a)}" 
                                                                    for="anexoImagem"
                                                                    style="margin-left:1%; width: 100px;" 
                                                                    rendered="#{a.tipo ne 'application/pdf'}"/>

                                                    <p:outputLabel for="anexoPdf"
                                                                   value="#{managerPesquisarProjeto.nomeAnexoPdf(a)}" 
                                                                   style="margin-left:1%; width: 100px;" 
                                                                   rendered="#{a.tipo eq 'application/pdf'}"/>
                                                </div>
                                                <f:param name="annex" value="#{a.url.concat(a.nome)}"/>
                                            </h:outputLink>
                                        </p:panel>
                                    </ui:repeat>
                                </div>
                            </p:panel>

                            <div class="clear"/>
                            <hr/>
                            <div class="clear"/>

                            <p:outputLabel value="Comentários:" style="font-weight: bold;" styleClass="grid_3" />
                            <p:outputLabel value="Não há comentários !" styleClass="grid_5" rendered="#{empty r.comentarios}"  />
                            <div class="clear"/>
                            <p:panel id="panelcomentario" styleClass="grid_23 clearfix" 
                                     style="overflow-y: auto; max-height: 500px;">
                                <ui:repeat id="repeatcomentario"  value="#{r.comentarios}" var="c">
                                    <div class="grid_24 commentseparator" >

                                        <div style="font-size: 0.9em; color:#065D9B;">
                                            <h:outputText rendered="#{c.dataCriacao ne null}" value="#{c.usuario.nome} em " />
                                            <h:outputText  value="#{c.dataCriacao}" >
                                                <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                                            </h:outputText>
                                        </div>
                                        <p:inputTextarea disabled="true"  value="#{c.descricao}" 
                                                         styleClass="grid_24" style="padding-left: 5px; opacity: 0.6;"/>

                                        <div class="clear"/>

                                        <p:outputLabel value="Anexo:" styleClass="grid_3" />

                                        <div class="grid_20">
                                            <ui:repeat value="#{c.anexo}" var="a">
                                                <p:panel styleClass="grid_5">
                                                    <h:outputLink  
                                                        value="#{a.tipo ne 'application/pdf' ? 'viewImage.xhtml':'show'}" title="#{a.tipo}"  target="_blank" >

                                                        <div style="width: 100%;" class="grid_4">

                                                            <p:graphicImage id="anexoImagem"
                                                                            styleClass="image grid_3" 
                                                                            rendered="#{a.tipo ne 'application/pdf'}"
                                                                            style="margin-left:3%; width: 80px;"
                                                                            url="show/?annex=#{a.url.concat('thumbnail.').concat(a.nome)}" />

                                                            <p:graphicImage id="anexoPdf"
                                                                            styleClass="image grid_3" rendered="#{a.tipo eq 'application/pdf'}"
                                                                            style="margin-left:3%; width: 80px;" 
                                                                            url="media/images/pdf.jpeg" />

                                                            <div class="clear"></div>
                                                            <p:outputLabel  value="#{managerCriarProtocolo.nomeAnexo(a)}" 
                                                                            for="anexoImagem"
                                                                            style="margin-left:1%; width: 100px;" 
                                                                            rendered="#{a.tipo ne 'application/pdf'}"/>

                                                            <p:outputLabel for="anexoPdf"
                                                                           value="#{managerCriarProtocolo.nomeAnexoPdf(a)}" 
                                                                           style="margin-left:1%; width: 100px;" 
                                                                           rendered="#{a.tipo eq 'application/pdf'}"/>
                                                        </div>
                                                        <f:param name="annex" value="#{a.url.concat(a.nome)}"/>
                                                    </h:outputLink>
                                                </p:panel>
                                            </ui:repeat>
                                        </div>

                                    </div>
                                    <div class="clear"/>

                                </ui:repeat>
                            </p:panel>
                            <div class="clear"/>
                            <p:outputLabel value="Comentar:" styleClass="grid_3" />
                            <p:inputTextarea styleClass="grid_20" id="comentarioInput" 
                                             value="#{managerPesquisarProjeto.comentario.descricao}"/>
                            <div class="clear"/>
                            <div class="clear"/>

                            <p:panel id="anexosComentarioPanel" >
                            <p:outputLabel value="Anexo:" styleClass="grid_3" />
                            <div class="grid_20">
                                <p:fileUpload 
                                    mode="advanced"
                                    id="fileuploadcomentario"
                                    label="Anexar"
                                    uploadLabel="Enviar"
                                    cancelLabel="Cancelar"
                                    fileUploadListener="#{managerPesquisarProjeto.handleAnnexComentario}"
                                    multiple="true"
                                    auto="true" 
                                    allowTypes="/(\.|\/)(gif|jpe?g|png|pdf)$/"
                                    dragDropSupport="true"
                                    invalidFileMessage="Tipo de arquivo não suportado."
                                    invalidSizeMessage="Tamanho do arquivo não é suportado"
                                    immediate="true" update="@this, :messagegrowl, :projetoForm:repeatsituacao:anexosComentarioPanel"/>
                            </div>

                            <div class="clear"/>

                                <p:outputLabel value="Arquivos:" styleClass="grid_5" style="margin-left: -70px;" />
                                <h:outputText value="Não há anexos!" rendered="#{empty managerPesquisarProjeto.anexoComentario}" 
                                              styleClass="grid_4" />

                                <div class="grid_20">
                                    <ui:repeat value="#{managerPesquisarProjeto.anexoComentario}" var="a">
                                        <p:panel styleClass="grid_5">
                                            <h:outputLink  
                                                value="#{a.tipo ne 'application/pdf' ? 'viewImage.xhtml':'show'}" title="#{a.tipo}"  target="_blank" >

                                                <div style="width: 100%;" class="grid_4">

                                                    <p:graphicImage id="anexoImagem"
                                                                    styleClass="image grid_3" rendered="#{a.tipo ne 'application/pdf'}"
                                                                    style="margin-left:3%; width: 80px;"
                                                                    url="show/?annex=#{a.url.concat('thumbnail.').concat(a.nome)}" />

                                                    <p:graphicImage id="anexoPdf"
                                                                    styleClass="image grid_3" rendered="#{a.tipo eq 'application/pdf'}"
                                                                    style="margin-left:3%; width: 80px;" 
                                                                    url="media/images/pdf.jpeg" />

                                                    <div class="clear"/>
                                                    <p:outputLabel  value="#{managerPesquisarProjeto.nomeAnexo(a)}" 
                                                                    for="anexoImagem"
                                                                    style="margin-left:1%; width: 100px;" rendered="#{a.tipo ne 'application/pdf'}"/>

                                                    <p:outputLabel for="anexoPdf"
                                                                   value="#{managerPesquisarProjeto.nomeAnexoPdf(a)}" 
                                                                   style="margin-left:1%; width: 100px;" rendered="#{a.tipo eq 'application/pdf'}"/>
                                                </div>
                                                <f:param name="annex" value="#{a.url.concat(a.nome)}"/>
                                            </h:outputLink>

                                            <p:commandButton id="removeButton" alt="Remover" value="Remover"
                                                             icon="ui-icon-trash" 
                                                             update=":projetoForm:repeatsituacao:anexosComentarioPanel"
                                                             actionListener="#{managerPesquisarProjeto.removerAnexoComentario(a)}" />
                                        </p:panel>
                                    </ui:repeat>
                                </div>
                            </p:panel>
                            <div class="clear"/>
                            
                            <p:commandButton icon="ui-icon-circle-check " value="Enviar" style="float:right; 
                                             margin-right: 30px; font-size: 0.8em;" partialSubmit="true"
                                             process="@this, :projetoForm:situacaoPanel, comentarioInput"
                                             update="@this, :projetoForm:situacaoPanel, :projetoForm:repeatsituacao, 
                                             comentarioInput" 
                                             actionListener="#{managerPesquisarProjeto.addComentario(count.index)}"
                                             styleClass="grid_3"/>
                            <div class="clear"/>
                        </p:panel>
                    </ui:repeat>
                </p:panel>
                <br/>
                <h3 class="subtitle">Lançamento</h3>
                <p:panel id="lancamentoPanel" styleClass="container_24 clearfix" >
                    <p:commandButton value="Novo"
                                     icon="ui-icon-plusthick" styleClass="ui-priority-primary" 
                                     style="margin-top: -50px; margin-right: 0px; float: right;"
                                     update="@this" process="@this" onclick="lancamentoDlg.show();"  />


                    <ui:repeat id="repeatlancamento"  value="#{managerPesquisarProjeto.lancamentosVisualizar}" var="l">
                        <p:panel id="panelrepeatlancamento" styleClass="grid_23 "  toggleable="true" collapsed="true" >
                            <f:facet name="header">
                                <div class="grid_23 clearfix">

                                    <h:outputLabel value="#{l.dataEntrada}">
                                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                                    </h:outputLabel>
                                    <h:outputText value=" - "/>
                                    <h:outputText value="#{l.valor}">
                                        <f:convertNumber type="currency" locale="pt,BR"/>
                                    </h:outputText>
                                </div>
                            </f:facet>
                            <div style="right:0 ; position: absolute; font-size: 0.8em;">
                                <h:outputText  rendered="#{l.dataCriacao ne null}" value="Criado por: #{l.usuario.nome} em " />
                                <h:outputText  value="#{l.dataCriacao}" >
                                    <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                                </h:outputText>
                            </div>
                            <div class="clear"/>
                            <p:outputLabel value="Destinatário:" styleClass="grid_3" />
                            <h:outputText styleClass="grid_20"   value="#{l.destino}"  />
                            <div class="clear"/>

                            <p:outputLabel value="Autorizado por:" styleClass="grid_4"  style="margin-left: -27px;" />
                            <h:outputText styleClass="grid_20"   value="#{l.responsavel}"  />
                            <div class="clear"/>

                            <p:outputLabel value="Descrição:" styleClass="grid_3" />
                            <h:outputText styleClass="grid_20"   value="#{l.descricao}"  />
                            <div class="clear"/>

                            <p:outputLabel value="Valor:" styleClass="grid_3" />
                            <h:outputText styleClass="grid_20" id="orcInputText" 
                                          value="#{l.valor}">
                                <f:convertNumber type="currency" locale="pt,BR"/>
                            </h:outputText>

                            <div class="clear"/>

                            <p:outputLabel value="Data:" styleClass="grid_3" />
                            <h:outputText styleClass="grid_20" value="#{l.dataEntrada}">
                                <f:convertDateTime pattern="dd/MM/yyyy" />
                            </h:outputText>

                            <div class="clear"/>
                            <hr/>
                            <div class="clear"/>

                            <p:panel id="anexoslancamentoPanel" styleClass="container_24 clearfix" style="margin-left: -2%;">

                                <p:outputLabel value="Anexos:" styleClass="grid_3" style="font-weight: bold;" />
                                <h:outputText value="Não há anexos!" rendered="#{empty l.anexos}" 
                                              styleClass="grid_4" />

                                <div class="grid_20">
                                    <ui:repeat value="#{l.anexos}" var="la">
                                        <p:panel styleClass="grid_5">
                                            <h:outputLink  
                                                value="#{a.tipo ne 'application/pdf' ? 'viewImage.xhtml':'show'}" title="#{la.tipo}"  
                                                target="_blank" >

                                                <div style="width: 100%;" class="grid_4">

                                                    <p:graphicImage id="anexoImagem"
                                                                    styleClass="image grid_3" rendered="#{la.tipo ne 'application/pdf'}"
                                                                    style="margin-left:3%; width: 80px;"
                                                                    url="show/?annex=#{la.url.concat('thumbnail.').concat(la.nome)}" />

                                                    <p:graphicImage id="anexoPdf"
                                                                    styleClass="image grid_3" rendered="#{la.tipo eq 'application/pdf'}"
                                                                    style="margin-left:3%; width: 80px;" 
                                                                    url="media/images/pdf.jpeg" />

                                                    <div class="clear"/>
                                                    <p:outputLabel  value="#{la.nome}" 
                                                                    for="anexoImagem"
                                                                    style="margin-left:1%; width: 100px;" 
                                                                    rendered="#{la.tipo ne 'application/pdf'}"/>

                                                    <p:outputLabel for="anexoPdf"
                                                                   value="#{la.nome}" 
                                                                   style="margin-left:1%; width: 100px;" 
                                                                   rendered="#{la.tipo eq 'application/pdf'}"/>
                                                </div>
                                                <f:param name="annex" value="#{la.url.concat(la.nome)}"/>
                                            </h:outputLink>
                                        </p:panel>
                                    </ui:repeat>
                                </div>
                            </p:panel>
                        </p:panel>
                    </ui:repeat>
                </p:panel>

                <h3 class="subtitle">Gráficos</h3>

                <p:lineChart id="grfLinear" legendPosition="e"  value="#{managerPesquisarProjeto.grf}" 
                             maxY="100" animate="true" 
                             minY="0" minX="0" maxX="100" xaxisAngle="#{managerPesquisarProjeto.situacoesVisualizar.size() ge 0 ? 20:0}" 
                             xaxisLabel="Datas das Situações" yaxisLabel="Percentual"/>
                <br/>
                <br/>

                <div class="buttonAction">
                    <p:button value="Voltar" icon="ui-icon-circle-arrow-w"
                              href="indexprojeto.xhtml"/>
                </div>

                <p:dialog widgetVar="situacaoDlg" dynamic="true" width="900" height="400" header="Nova Situação" resizable="false">
                    <p:panel id="panelSituacao" styleClass="container_24 clearfix">
                        <p:outputLabel value="Status:" styleClass="grid_3" />
                        <div class="grid_10">
                            <p:selectOneMenu panelStyle="width: 45%;" 
                                             value="#{managerPesquisarProjeto.situacaoCriar.projetoStatus}" >
                                <f:selectItems value="#{managerPesquisarProjeto.selectProjetoStatus()}"/>
                            </p:selectOneMenu>
                        </div>

                        <p:outputLabel value="Estágio" styleClass="grid_3" />
                        <p:inputText styleClass="grid_7" required="true" label="Estágio" 
                                     value="#{managerPesquisarProjeto.situacaoCriar.estagio}"
                                     onkeypress="jQuery(this).autoNumeric({aSign:'%', pSign:'s', vMax:'100'} );">
                            <f:convertNumber type="percent" locale="pt,BR"/>
                        </p:inputText>

                        <div class="clear"/>

                        <p:outputLabel value="Título" styleClass="grid_3" />
                        <p:inputText styleClass="grid_20" required="true" label="Título"
                                     value="#{managerPesquisarProjeto.situacaoCriar.titulo}" />

                        <div class="clear"/>
                        <p:outputLabel value="Descrição:" styleClass="grid_3" />
                        <p:inputTextarea styleClass="grid_20"  label="Descrição"
                                         value="#{managerPesquisarProjeto.situacaoCriar.descricao}" />

                        <div class="clear"/>
                        <p:outputLabel value="Em:" styleClass="grid_3" />
                        <p:calendar styleClass="grid_10" value="#{managerPesquisarProjeto.situacaoCriar.dataEntrada}" 
                                    showOn="both" pattern="dd/MM/yyyy" />

                        <div class="clear"/>

                        <p:outputLabel  for="notificar" value="Notificar:" styleClass="grid_3"/>

                        <p:outputLabel  for="notificar" value="Empresa" styleClass="grid_2"/>
                        <p:selectBooleanCheckbox id="notificar" label="Notificar" styleClass="grid_2" 
                                                 value="#{managerPesquisarProjeto.situacaoCriar.notificar}" />

                        <p:outputLabel  for="notificarempresa" value="Secretaria" styleClass="grid_2"/>
                        <p:selectBooleanCheckbox id="notificarempresa" label="Notificar" styleClass="grid_4" 
                                                 value="#{managerPesquisarProjeto.situacaoCriar.notificarempresa}" />
                        <div class="clear"/>

                        <p:outputLabel  for="secsituacaoInput" value="Campus:" styleClass="grid_3"/>  
                        <div class="grid_20"> 
                            <p:selectOneMenu value="#{managerPesquisarProjeto.secretariaSituacao}" id="secsituacaoInput" 
                                             converter="secretariaconverter" >  
                                <f:selectItem  itemValue="" itemLabel=""/>
                                <f:selectItems value="#{managerPesquisarProjeto.todasSecretarias()}" var="p" 
                                               itemLabel="#{p.nome}" itemValue="#{p}"/>  
                            </p:selectOneMenu> 
                        </div>

                        <div class="clear"/>

                        <p:outputLabel value="Responsável Projeto:" styleClass="grid_5" style="margin-left: -61px" />
                        <p:inputText styleClass="grid_20" id="respprojetodlg" readonly="true"
                                     style="width: #{managerPesquisarProjeto.usuarioNotificar.id eq null ? '78%;':'74.5%'}"
                                     value="#{managerPesquisarProjeto.usuarioNotificar.nome}"/>
                        <p:panel id="buttonsRespPanel" style="background: none; border: none; margin-top: -10px; height: 10px;">
                            <p:commandButton icon="ui-icon-plus" style="margin-left: -8px;" oncomplete="dlgresp.show();"
                                             update="@this" process="@this"/>
                            <p:commandButton id="removerResponsavelCommandButton" icon="ui-icon-trash" 
                                             update=":projetoForm:respprojetodlg, :projetoForm:buttonsRespPanel, @this"
                                             process="@this" immediate="true" 
                                             rendered="#{managerPesquisarProjeto.usuarioNotificar.id ne null}"
                                             actionListener="#{managerPesquisarProjeto.removerResponsavel()}"/>
                        </p:panel>

                        <div class="clear"/>

                        <p:outputLabel value="Anexo:" styleClass="grid_3" />
                        <div class="grid_20">
                            <p:fileUpload 
                                mode="advanced"
                                label="Anexar"
                                uploadLabel="Enviar"
                                cancelLabel="Cancelar"
                                fileUploadListener="#{managerPesquisarProjeto.handleAnnex}"
                                multiple="true"
                                auto="true"
                                allowTypes="/(\.|\/)(gif|jpe?g|png|pdf)$/"
                                dragDropSupport="true"
                                invalidFileMessage="Tipo de arquivo não suportado."
                                invalidSizeMessage="Tamanho do arquivo não é suportado"
                                immediate="true"
                                update=":projetoForm:anexosPanel" />
                        </div>
                    </p:panel>


                    <p:panel id="anexosPanel" styleClass="container_24 clearfix">

                        <p:outputLabel value="Arquivos anexados:" styleClass="grid_4" style="margin-left: -20px;" />
                        <h:outputText value="Não há anexos!" rendered="#{empty managerPesquisarProjeto.situacaoCriar.anexos}" 
                                      styleClass="grid_4" />

                        <div class="grid_20">
                            <ui:repeat value="#{managerPesquisarProjeto.situacaoCriar.anexos}" var="a">
                                <p:panel styleClass="grid_5">
                                    <h:outputLink  
                                        value="#{a.tipo ne 'application/pdf' ? 'viewImage.xhtml':'show'}" title="#{a.tipo}"  
                                        target="_blank" >

                                        <div style="width: 100%;" class="grid_4">

                                            <p:graphicImage id="anexoImagem"
                                                            styleClass="image grid_3" rendered="#{a.tipo ne 'application/pdf'}"
                                                            style="margin-left:3%; width: 80px;"
                                                            url="show/?annex=#{a.url.concat('thumbnail.').concat(a.nome)}" />

                                            <p:graphicImage id="anexoPdf"
                                                            styleClass="image grid_3" rendered="#{a.tipo eq 'application/pdf'}"
                                                            style="margin-left:3%; width: 80px;" 
                                                            url="media/images/pdf.jpeg" />

                                            <div class="clear"></div>
                                            <p:outputLabel  value="#{managerPesquisarProjeto.nomeAnexo(a)}" 
                                                            for="anexoImagem"
                                                            style="margin-left:1%; width: 100px;" rendered="#{a.tipo ne 'application/pdf'}"/>

                                            <p:outputLabel for="anexoPdf"
                                                           value="#{managerPesquisarProjeto.nomeAnexoPdf(a)}" 
                                                           style="margin-left:1%; width: 100px;" rendered="#{a.tipo eq 'application/pdf'}"/>
                                        </div>
                                        <f:param name="annex" value="#{a.url.concat(a.nome)}"/>
                                    </h:outputLink>

                                    <p:commandButton id="removeButton" alt="Remover" value="Remover"
                                                     icon="ui-icon-trash" update=":projetoForm:anexosPanel"
                                                     actionListener="#{managerPesquisarProjeto.removerAnexo(a)}" />
                                </p:panel>
                            </ui:repeat>
                        </div>
                    </p:panel>
                    <f:facet name="footer">
                        <div class="buttonAction">
                            <p:commandButton value="Salvar" actionListener="#{managerPesquisarProjeto.salvarSituacao()}"
                                             icon="ui-icon-disk" styleClass="ui-priority-primary" onclick="situacaoDlg.hide();"
                                             update="@this, :projetoForm:panelSituacao, :projetoForm:anexosPanel, :projetoForm:situacaoPanel, 
                                             :projetoForm:grfLinear" process="@this, :projetoForm:panelSituacao, :projetoForm:anexosPanel, :projetoForm:panelSituacao"  />
                            <p:commandButton value="Cancelar" icon="ui-icon-circle-close"
                                             process="@this" update="@this" immediate="true"
                                             onclick="situacaoDlg.hide()"/>
                        </div>
                    </f:facet>

                </p:dialog>

                <p:dialog widgetVar="lancamentoDlg" dynamic="true" width="900" resizable="false" height="400" header="Novo Lançamento" >
                    <p:panel id="panelLancamento" styleClass="container_24 clearfix">

                        <p:outputLabel value="Destinatário:" styleClass="grid_3" />
                        <p:inputText styleClass="grid_20" value="#{managerPesquisarProjeto.lancamentoCriar.destino}" />

                        <div class="clear"/>

                        <p:outputLabel value="Autorizado por:" styleClass="grid_4" style="margin-left: -27px;" />
                        <p:inputText styleClass="grid_20" value="#{managerPesquisarProjeto.lancamentoCriar.responsavel}" />

                        <div class="clear"/>

                        <p:outputLabel value="Descrição:" styleClass="grid_3" />
                        <p:inputText styleClass="grid_20" value="#{managerPesquisarProjeto.lancamentoCriar.descricao}" />

                        <div class="clear"/>

                        <p:outputLabel value="Valor:" styleClass="grid_3" />
                        <p:inputText styleClass="grid_20"  value="#{managerPesquisarProjeto.lancamentoCriar.valor}"
                                     onkeypress="jQuery(this).autoNumeric({aSign:'R$ ', aSep: '.', aDec: ','} );">
                            <f:convertNumber type="currency" locale="pt,BR"/>
                        </p:inputText>


                        <div class="clear"/>
                        <p:outputLabel value="Em:" styleClass="grid_3" />
                        <p:calendar styleClass="grid_10" value="#{managerPesquisarProjeto.lancamentoCriar.dataEntrada}" showOn="both" />

                        <div class="clear"/>

                        <p:outputLabel value="Anexo:" styleClass="grid_3" />
                        <div class="grid_20">
                            <p:fileUpload 
                                mode="advanced"
                                label="Anexar"
                                uploadLabel="Enviar"
                                cancelLabel="Cancelar"
                                fileUploadListener="#{managerPesquisarProjeto.handleAnnexLancamento}"
                                multiple="true"
                                auto="true"
                                allowTypes="/(\.|\/)(gif|jpe?g|png|pdf)$/"
                                dragDropSupport="true"
                                invalidFileMessage="Tipo de arquivo não suportado."
                                invalidSizeMessage="Tamanho do arquivo não é suportado"
                                immediate="true"
                                update=":projetoForm:anexosLancamentoPanel" />
                        </div>
                    </p:panel>


                    <p:panel id="anexosLancamentoPanel" styleClass="container_24 clearfix">

                        <p:outputLabel value="Arquivos anexados:" styleClass="grid_4" style="margin-left: -20px;" />
                        <h:outputText value="Não há anexos!" rendered="#{empty managerPesquisarProjeto.lancamentoCriar.anexos}" 
                                      styleClass="grid_4" />

                        <div class="grid_20">
                            <ui:repeat value="#{managerPesquisarProjeto.lancamentoCriar.anexos}" var="a">
                                <p:panel styleClass="grid_5">
                                    <h:outputLink  
                                        value="#{a.tipo ne 'application/pdf' ? 'viewImage.xhtml':'show'}" title="#{a.tipo}"  
                                        target="_blank" >

                                        <div style="width: 100%;" class="grid_4">

                                            <p:graphicImage id="anexoImagem"
                                                            styleClass="image grid_3" rendered="#{a.tipo ne 'application/pdf'}"
                                                            style="margin-left:3%; width: 80px;"
                                                            url="show/?annex=#{a.url.concat('thumbnail.').concat(a.nome)}" />

                                            <p:graphicImage id="anexoPdf"
                                                            styleClass="image grid_3" rendered="#{a.tipo eq 'application/pdf'}"
                                                            style="margin-left:3%; width: 80px;" 
                                                            url="media/images/pdf.jpeg" />

                                            <div class="clear"></div>
                                            <p:outputLabel  value="#{a.nome}" 
                                                            for="anexoImagem"
                                                            style="margin-left:1%; width: 100px;" 
                                                            rendered="#{a.tipo ne 'application/pdf'}"/>

                                            <p:outputLabel for="anexoPdf"
                                                           value="#{a.nome}" 
                                                           style="margin-left:1%; width: 100px;" 
                                                           rendered="#{a.tipo eq 'application/pdf'}"/>
                                        </div>
                                        <f:param name="annex" value="#{a.url.concat(a.nome)}"/>
                                    </h:outputLink>

                                    <p:commandButton id="removeButton" alt="Remover" value="Remover"
                                                     icon="ui-icon-trash" update=":projetoForm:anexosLancamentoPanel"
                                                     actionListener="#{managerPesquisarProjeto.removerAnexoLancamento(a)}" />
                                </p:panel>
                            </ui:repeat>
                        </div>
                    </p:panel>
                    <f:facet name="footer">
                        <div class="buttonAction">
                            <p:commandButton value="Salvar" actionListener="#{managerPesquisarProjeto.salvarLancamento()}"
                                             icon="ui-icon-disk" styleClass="ui-priority-primary" onclick="lancamentoDlg.hide();"
                                             update="@this, :projetoForm:lancamentoPanel" process="@this, :projetoForm:panelLancamento"  />
                            <p:commandButton value="Cancelar" icon="ui-icon-circle-close"
                                             process="@this" update="@this" immediate="true"
                                             onclick="lancamentoDlg.hide()"/>
                        </div>
                    </f:facet>

                </p:dialog>

                <p:dialog id="responsavelDialog" header="Usuário Responsável" widgetVar="dlgresp" modal="false"
                          width="750" resizable="false" height="400">  

                    <p:panel id="responsavelPanel" styleClass="container_24 clearfix">
                        <p:outputLabel value="Nome:" styleClass="grid_3"/>
                        <p:inputText  styleClass="grid_20" value="#{managerPesquisarProjeto.usuarioNotificar.nome}"/>

                        <div class="buttonAction">
                            <p:commandButton value="Pesquisar" actionListener="#{managerPesquisarProjeto.pesquisarResponsavel()}"  
                                             icon="ui-icon-search" styleClass="ui-priority-primary"
                                             process="@this, :projetoForm:responsavelPanel" update="@this, :projetoForm:responsavelPanel"/>

                        </div>

                        <p:dataTable id="responsavelTable" var="item" value="#{managerPesquisarProjeto.usuarios}" 
                                     styleClass="grid_24" rowIndexVar="rowid" 
                                     style="white-space: pre-wrap;"
                                     rowKey="#{item.id}" rows="5" paginator="true"  
                                     paginatorPosition="bottom" emptyMessage="Nenhum registro">  
                            <f:facet name="header">
                                <p:outputLabel value="Usuários" />
                            </f:facet>
                            <p:column headerText="Ação" width="10px;" > 
                                <p:commandButton icon="ui-icon-check"
                                                 actionListener="#{managerPesquisarProjeto.setarResponsavel(item)}"
                                                 onclick="dlgresp.hide();"
                                                 process="@this, :projetoForm:respprojetodlg"
                                                 update=":projetoForm:respprojetodlg, @this, :projetoForm:buttonsRespPanel"/>
                            </p:column>
                            <p:column headerText="Nome"> 
                                <p:outputLabel value="#{item.nome}"/>
                            </p:column>
                            <p:column headerText="Campus">
                                <p:outputLabel value="#{item.setor.secretaria.nome}"/>
                            </p:column>

                        </p:dataTable>
                    </p:panel>
                    <div class="buttonAction">
                        <p:commandButton value="Sair" process="@this" onclick="dlgresp.hide()" icon="ui-icon-close" />
                    </div>
                </p:dialog>

            </h:form>
        </ui:define>
    </ui:composition>
</html>
